home *** CD-ROM | disk | FTP | other *** search
/ TPUG - Toronto PET Users Group / TPUG Users Group CD / TPUG Users Group CD.iso / AMIGA / AMICUS / AMICUS26.ADF / SoundScape / LatticeExamples / chord.c < prev    next >
C/C++ Source or Header  |  1989-01-26  |  2KB  |  131 lines

  1. /*    Chord.c
  2.  
  3.     (c) 1987    Todor Fay
  4.  
  5.     Lattice version
  6.  
  7.     To compile:
  8.     lc1 chord
  9.     lc2 -v chord
  10.  
  11.     To link:
  12.     alink with chord.with
  13.         or
  14.     blink with chord.with
  15. */
  16.  
  17. #include "exec/types.h"
  18. #include "exec/exec.h"
  19. #include "intuition/intuition.h"
  20. #include "soundscape.h"
  21.  
  22. /*    First, the data for the icon in the Patch Panel  */
  23.  
  24. UWORD chorddata[] = {
  25. 0,    0,    
  26. 0,    0,    
  27. 0,    0,    
  28. 0,    0,    
  29. 0,    0,    
  30. 6,    0,    
  31. 1,    32768,    
  32. 255,    57344,    
  33. 1,    32768,    
  34. 6,    0,    
  35. 0,    0,    
  36. 0,    0,    
  37. 0,    0,    
  38. 0,    0,    
  39. 0,    0,    
  40. 0,    0,    
  41. 0,    96,    
  42. 0,    96,    
  43. 3072,    96,    
  44. 3072,    992,    
  45. 3072,    992,    
  46. 3072,    96,    
  47. 3072,    96,    
  48. 31744,    992,    
  49. 31744,    992,    
  50. 0,    96,    
  51. 0,    96,    
  52. 0,    992,    
  53. 0,    992,    
  54. 0,    0,    
  55. 0,    0,    
  56. 0,    0,    
  57. };
  58.  
  59. struct Image chordimage = { 0,0,32,16,2,chorddata,3,0,0 };
  60.  
  61. /*    This module has a port id. */
  62.  
  63. unsigned short thisport;
  64.  
  65. opencode(direction)
  66.  
  67. /*    Always happy to open. */
  68.  
  69. unsigned char direction;
  70.  
  71. {
  72.     return(1);
  73. }
  74.  
  75. closecode(direction)
  76.  
  77. unsigned char direction;
  78.  
  79. {
  80.     return(1);
  81. }
  82.  
  83. outcode(event)
  84.  
  85. /*    Strip the channel information from the status byte.  If
  86.     this is a NOTEON or NOTEOFF event, create two new events,
  87.     copy the status and velocity into them, add constants to
  88.     their note values, and ship off all three.   Otherwise, 
  89.     free this event.
  90. */
  91.  
  92. struct Note *event;
  93.  
  94. {
  95.     struct Note *secondevent;
  96.     unsigned char status;
  97.     status = event->status & 0xF0;
  98.     if ((status == NOTEON) || (status == NOTEOFF)) {
  99.     secondevent = (struct Note *) AllocNode(NOTE);
  100.     if (secondevent) {
  101.         secondevent->status = event->status;
  102.         secondevent->velocity = event->velocity;
  103.         secondevent->value = event->value + 4;
  104.         Send(thisport,secondevent);
  105.     }
  106.     secondevent = (struct Note *) AllocNode(NOTE);
  107.     if (secondevent) {
  108.         secondevent->status = event->status;
  109.         secondevent->velocity = event->velocity;
  110.         secondevent->value = event->value + 7;
  111.         Send(thisport,secondevent);
  112.     }
  113.         Send(thisport,event);
  114.     }
  115.     else FreeNode(event);
  116. }
  117.  
  118. long SoundScapeBase;
  119.  
  120. main() {
  121.     SoundScapeBase = OpenLibrary("soundscape.library",0);
  122.     if (SoundScapeBase) {
  123.     CloseLibrary(SoundScapeBase);
  124.     thisport = AddMidiPort(opencode,closecode,0,outcode,&chordimage,
  125.         &chordimage,-1,"chord maker");    
  126.     SetTaskPri(FindTask(0),-20);
  127.     while (MidiPort(thisport)) Delay(100);
  128.     }
  129. }
  130.  
  131.